*Paper: "The Gender Promotion Gap: Evidence from Central Banking" (RESTAT MS 22860)
*File: Graphs_Profiles.do
*Authors: Laura Hospido (laura.hospido@bde.es) & Luc Laeven (Luc.laeven@ecb.int) & Ana Lamo (ana.lamo@ecb.int)
*This version: October 2020
*---------------------------------------------------------------------------

clear all
set more off
global master_ECB `""D:\Data""' /*to be changed by the user*/
cd $master_ECB

**---------------------------------------------------------------------------
** Figure 1:  Wages since entry at Expert level (2003-2017) ***
**---------------------------------------------------------------------------

*** Overall: Salaries since entry in F/G  ***

import delimited profiles, case(preserve) clear
run labels1.do
keep if entry_band=="F/G"

gen time=trunc(entry/12)
bys time: egen meanstep=mean(steptotal)
bys time: egen male_meanstep=mean(steptotal) if female==0
bys time: egen female_meanstep=mean(steptotal) if female==1
bys time female:gen n=_n
keep if n==1
keep time female male_meanstep female_meanstep

sort time
sc male_meanstep female_meanstep time if time<=16,c(l l) scheme(s1mono) xtitle("Years since entry in Expert level") legend(label(1 "Men") label(2 "Women")) /*
*/ msymbol(i i) lwidth(thick thick) ylabel(275(50)475) xlabel(0 5 10 15) lcolor(black gray)  mlabposition(12 6) mlabsize(medsmall medsmall) title("Overall") /*
*/ mlabcolor(black gray)
graph save Graph "SalariesSinceEntry.gph", replace

*** Within expert level

import delimited profiles, case(preserve) clear
run labels1.do
keep if entry_band=="F/G"

gen changed=(salaryband=="H"|salaryband=="I")
keep if changed==0
gen time=trunc(entry/12)
bys time: egen male_meanstep=mean(steptotal) if female==0
bys time: egen female_meanstep=mean(steptotal) if female==1
bys time female:gen n=_n
keep if n==1
keep time female male_meanstep female_meanstep

sort time
sc male_meanstep female_meanstep time if time<=16,c(l l) scheme(s1mono) xtitle("Years since entry in Expert level") legend(label(1 "Men") label(2 "Women")) /*
*/ msymbol(i i) lwidth(thick thick) ylabel(275(50)475) xlabel(0 5 10 15) lcolor(black gray) mlabel() mlabposition(12 6) mlabsize(medsmall medsmall) title("Within Expert level") /*
*/ mlabcolor(black gray)
graph save Graph "SalariesSinceEntry_within.gph", replace

*** Both
gr combine "SalariesSinceEntry.gph" "SalariesSinceEntry_within.gph" , scheme(s1mono) title("Fig.1: Wages since entry at Expert level (2003-2017)")
graph export "Figure1.pdf", as(pdf) replace
erase "SalariesSinceEntry.gph"
erase "SalariesSinceEntry_within.gph"

**---------------------------------------------------------------------------
** Figure 2: Probability of promotion at Expert level, % (2003-2017) ***
**---------------------------------------------------------------------------
import delimited profiles, case(preserve) clear
run labels1.do
keep if entry_band=="F/G"

gen changed=(salaryband=="H"|salaryband=="I")
gen time=trunc(entry/12)
bys time: egen male_changed=mean(changed) if female==0
bys time: egen female_changed=mean(changed) if female==1
bys time female:gen n=_n
keep if n==1
keep time female male_changed female_changed
replace male_changed=male_changed*100
replace female_changed=female_changed*100

sort time female
sc male_changed female_changed time if time<11,c(l l) scheme(s1mono) xtitle("Years since entry in Expert level") legend(label(1 "Men") label(2 "Women"))  msymbol(i i) /*
*/ msymbol(i i) lwidth(thick thick)  xlabel(0(2)10) lcolor(black gray) mlabel() mlabposition(12 6) mlabsize(medsmall medsmall)  /*
*/ mlabcolor(black gray) title("Fig.2: Probability of promotion at Expert level, % (2003-2017)")
graph export "Figure2.pdf", as(pdf) replace

**---------------------------------------------------------------------------
** Figure 3: Gender gap in promotion probability before and after 2011 ***
**---------------------------------------------------------------------------
import delimited profiles, case(preserve) clear
run labels1.do
keep if entry_band=="F/G"
keep if year<=2010

gen changed=(salaryband=="H"|salaryband=="I")
gen time=trunc(entry/12)
bys time: egen male_changed=mean(changed) if female==0
bys time: egen female_changed=mean(changed) if female==1
bys time female:gen n=_n
keep if n==1
keep time female male_changed female_changed
bys time: egen male_before=max(male_changed)
bys time: egen female_before=max(female_changed)
bys time:gen n=_n
keep if n==1
keep time male_before female_before
sort time
save temp1, replace

import delimited profiles, case(preserve) clear
run labels1.do
keep if entry_band=="F/G"
keep if year>=2011

gen changed=(salaryband=="H"|salaryband=="I")
gen time=trunc(entry/12)
bys time: egen male_changed=mean(changed) if female==0
bys time: egen female_changed=mean(changed) if female==1
bys time female:gen n=_n
keep if n==1
keep time female male_changed female_changed
bys time: egen male_after=max(male_changed)
bys time: egen female_after=max(female_changed)
bys time:gen n=_n
keep if n==1
keep time male_after female_after
sort time
merge time using temp1
erase temp1.dta
keep if _merge==3
sort time
gen gap_before=male_before-female_before
gen gap_after=male_after-female_after
replace gap_before= gap_before*100
replace gap_after=gap_after*100

sort time
sc gap_before gap_after time if time<11,c(l l) scheme(s1mono) xtitle("Years since entry in F/G")  legend(label(1 "Before 2011") label(2 "From 2011 onwards"))  msymbol(i i) /*
*/ msymbol(i i) lwidth(thick thick)  xlabel(0(2)10) lcolor(black gray) mlabel() mlabposition(12 6) mlabsize(medsmall medsmall)  /*
*/ mlabcolor(black gray) title("Fig.3: Gender gap in promotion prob. before & after 2011, %") 
graph export "Figure3.pdf", as(pdf) replace

*---------------------------------------------------------------------------	 
*** Figure A.1: Share of female employees over time (2003-2017)***
*---------------------------------------------------------------------------

import delimited profiles, case(preserve) clear
run labels1.do

tab salaryband,gen(band)
bys year: egen female_band1=mean(female) if band1==1
bys year: egen female_band2=mean(female) if band2==1
bys year: egen female_band3=mean(female) if band3==1
bys year salaryband: keep if _n==1
keep year female_band* 

sort year
sc female_band1 female_band2 female_band3 year, scheme(s1mono) c(l l l) xlabel(2003(2)2017) xtitle("Year") msymbol(i i i) /*
*/ lcolor(black gray gray*.6) lpattern(solid longdash shortdash) lwidth(thick thick thick) legend(rows(1) /*
*/ label(1 "Expert") label(2 "Principal expert") label(3 "Adviser")) ytitle("Female share") /*
*/ title("Fig.A.1: Share of female employees over time (2003-2017)")
graph export "FigureA1.pdf", as(pdf) replace
